﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HA.ModFlow.Domain.DomainLayer;
using HA.Data ;

namespace HA.ModFlow.Controls.Windows.DataOperation
{
    /// <summary>
    /// winModelChecker.xaml 的交互逻辑
    /// </summary>
    public partial class winModelChecker : Window
    {
        public winModelChecker(Project project)
        {
            InitializeComponent();
            this._grid = project.MfData.GridData;

            _project = project;


        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
        Project _project;
        GridData _grid;
        private void btnFixLayer_Click(object sender, RoutedEventArgs e)
        {
            winLayerErrorModifier win = new winLayerErrorModifier(this._grid);
            win.Owner = this;
            win.ShowDialog();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {

            // CheckModel
            //ModelFacotry checkModel = new CheckModflow(_project.MfData);
        }

        private void btnRunCheck_Click(object sender, RoutedEventArgs e)
        {
            CheckModel modflowCheckModel = new CheckModel(CheckModelType.ModflowSimulation, _project);

            modflowCheckModel.DisplaySetup.IsSuppressWarnings = this.chkWarming.IsChecked.Value;
            if (this.rbtnDisplayAll.IsChecked.Value)
            {
                modflowCheckModel.DisplaySetup.IsDisplayAllErrors = true;
            }
            else
            {
                modflowCheckModel.DisplaySetup.IsDisplayAllErrors = false;
            }
            try
            {
                modflowCheckModel.DisplaySetup.DisplayErrorsMaxNum = Convert.ToInt16(this.txtMax.Text);
            }
            catch
            {
                modflowCheckModel.DisplaySetup.DisplayErrorsMaxNum = 5;
            }
            bool b = modflowCheckModel.CheckModelData();
            if (b)
            {
                GridView gridview = new GridView();
                GridViewColumn col = new GridViewColumn();
                col.DisplayMemberBinding = new Binding("MessageStr");
                gridview.Columns.Add(col);
                lstView.View = gridview;
                lstView.ItemsSource = modflowCheckModel.CheckResult;
            }
        }
    }
}
